home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / DarkForge2000 / snippets_vol3 / snip_3dstarfield.dba < prev    next >
Encoding:
Text File  |  2000-09-30  |  972 b   |  49 lines

  1. `    -------------------------------------------------------------------------
  2. `    3D Starfield                                  DarkForge Snippet 27/9/2000
  3. `    -------------------------------------------------------------------------
  4. `    Flying into a 2D starfield. Change stars value for more/less and the 
  5. `    slide value for more/less distortion.
  6.  
  7. sync rate 0
  8. sync on
  9. hide mouse
  10.  
  11. randomize timer()
  12.  
  13. create bitmap 1,640,480
  14.  
  15. stars=500
  16.  
  17. dim x#(stars) 
  18. dim y#(stars)
  19.  
  20. for i = 1 to stars
  21.     x#(i)=rnd(640.0)-320.0
  22.     y#(i)=rnd(480.0)-240.0
  23. next i
  24.  
  25. sx#=1.03985 : sy#=1.03985
  26. slidex#=320.0 : slidey#=240.0
  27.  
  28. ink rgb(255,255,255),0
  29.  
  30. do
  31.  
  32.     cls 0
  33.  
  34.     for j=1 to stars
  35.         dot x#(j)+slidex#,y#(j)+slidey#
  36.         x#(j)=x#(j)*sx#
  37.         y#(j)=y#(j)*sy#
  38.         if x#(j) > 640.0 then x#(j)=x#(j)-640.0
  39.         if y#(j) > 480.0 then y#(j)=y#(j)-480.0
  40.         if x#(j) < -640.0 then x#(j)=x#(j)+640.0
  41.         if y#(j) < -480.0 then y#(j)=y#(j)+480.0
  42.     next j
  43.  
  44.     copy bitmap 1,0
  45.     sync 
  46.  
  47. loop
  48.  
  49.